-- @owner: @wan005
-- @date: 2022/05/06
-- @testpoint: bigint(n)作为对象名测试，部分测试点合理报错
--前提条件：兼容B类型数据库已经创建

--step1:作为列名  expect:成功
drop table if exists bigint_test cascade;
create table bigint_test(bigint bigint('asd'));
insert into bigint_test values('0');

--step2:作为索引名 expect:成功
create index on bigint_test(bigint);
drop table if exists bigint_test cascade;

--step3:作为表名  expect:成功
drop table if exists bigint cascade;
create table bigint(bigint bigint);
insert into bigint values('1');
select * from bigint;

--step4:作为数据库名  expect:成功
drop database if exists bigint;
create database bigint;
drop database bigint;

--step4:作为外部数据源名 expect:成功
drop data source if exists bigint;
create data source bigint;
drop data source bigint;

--step5:作为自定义函数名 expect:合理报错
create or replace function bigint(c1 bigint(666))
returns bigint(666)
as  $$
begin
    return c1;
end;
$$language plpgsql;
/
--step6:作为存储过程名 expect:合理报错
CREATE OR REPLACE PROCEDURE bigint(P1 IN bigint(666)) AS
BEGIN
insert into t_bigint_0023 values ('00001');
raise info '测试bigint作为存储过程名';
END;
/
--step7:作为角色名  expect:成功
drop role if exists bigint;
create role bigint with password 'gauss@123' valid until '2001-12-12';
drop role bigint;

--step8:作为用户组名 expect:成功
drop group if exists bigint;
create group bigint with password 'gauss@123';
drop group bigint;

--step9:作为模式名 expect:成功
drop schema if exists bigint;
create schema bigint;
drop schema bigint;

--step10:作为序列名  expect:合理报错
create sequence public.bigint start 100 cache 50;
drop sequence public.bigint;

--step11:作为用户名 expect:成功
drop user if exists bigint;
CREATE USER bigint PASSWORD 'Bigdata@123';
drop user bigint;

--step12:作为前置条件名 expect:成功
drop table if exists bigint_test cascade;
create table bigint_test(cid int,fid int);

--step13:作为游标名  expect:成功
start transaction;
cursor bigint for select * from bigint_test order by 1;
close bigint;
end;

--step14:清理环境 expect:成功
drop table if exists bigint_test cascade;
drop table if exists bigint cascade;